<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>旅游推荐</title>
<link href="css/standard.css" type="text/css" rel="stylesheet" />
<link href="css/airforceone.css" type="text/css" rel="stylesheet"/>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/>
 <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
</head>
<body>
<script>
$(document).ready(function(){ 
	var pathName=window.document.location.pathname;
	var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
$.ajax({
	type : 'POST',
	url : projectName+"/classify/orign",
	async : false,
	success : function(data,status){ 
        if(status == "success"){  
            var objs = eval(jQuery.parseJSON(data));  
            var name = "";
            var id = "";
            var html = "<ul id='mem-menual' class='Game-Menual'>";
            for(var key in objs){
            	id = objs[key].classify_id;
            	name = objs[key].classify_name;
            	html += "<div id=\""+id+"\"><li><a href='#' onclick=\"getClassifysById('"+id+"','"+name+"')\"><span>"+name+"</span></a></li></div>";
            }
            html += "</ul>"
            $("#menu_div").html(html);
        }  
	}
});
	}); 
</script>
<script>
function getClassifysById(classifyId,classifyName){
	var pathName=window.document.location.pathname;
	var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
$.ajax({
	type : 'POST',
	url : projectName+"/classify/children",
	data : "classifyId="+classifyId,
	async : false,
	success : function(data,status){ 
        if(status == "success"){  
        	loadMsg(data,classifyId,classifyName);
        }  
	}
});
}
//更新分类名
function updateClassify(classifyId,classify_pid,classify_pname){
	var pathName=window.document.location.pathname;
	var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
		//获取classifyName
		var classifyName = document.getElementById("classifyName_"+classifyId).value;
		$.ajax({
			type : 'POST',
			url : projectName+"/classify/update",
			data : "classifyId="+classifyId+"&classifyName="+classifyName+"&classify_pid="+classify_pid,
			async : false,
			success : function(data,status){ 
		        if(status == "success"){  
		        	loadMsg(data,classify_pid,classify_pname);
		        }  
			}
		});
		
}
//删除分类
function deleteClassify(classifyId,classify_pid,classify_pname){
	if(confirm("您确定要删除该分类吗？")){
	var pathName=window.document.location.pathname;
	var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
		$.ajax({
			type : 'POST',
			url : projectName+"/classify/delete",
			data : "classifyId="+classifyId+"&classify_pid="+classify_pid,
			async : false,
			success : function(data,status){ 
		        if(status == "success"){  
		        	loadMsg(data,classify_pid,classify_pname);
		        }  
			}
		});
	}	
}
//新增分类
function addClassify(){
	
	
	//获取父id
	var classify_pid = document.getElementById("classify_pid").value;
	var classify_pname = document.getElementById("classify_pname").value;
	//var formData = new FormData($( "#classifyForm" )[0]);  
	var image = document.getElementById("image").value;
	var formData = $('#classifyForm').serialize(); //普通参数序列化 文件无序列化
		var pathName=window.document.location.pathname;
		var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
			$.ajax({
				type : 'POST',
				url : projectName+"/classify/add",
				data : formData+"&image="+image,
				async : false,
				success : function(data,status){ 
			        if(status == "success"){  
			        	loadMsg(data,classify_pid,classify_pname);
			        }  
				}
			});
			/**
			var classify_pid = document.getElementById("classify_pid").value;
			var classify_pname = document.getElementById("classify_pname").value;
            $('#classifyForm').ajaxSubmit({
                success:function(data,status){
			        if(status == "success"){  
			        	loadMsg(data,classify_pid,classify_pname);
			        } 
                 }
             });
	*/
}
//关闭菜单栏的二级菜单
function closeChildrenClassifys(classifyId,classifyName){
	var html = "<li><a href='#' onclick=\"getClassifysById('"+classifyId+"','"+classifyName+"')\"><span>"+classifyName+"</span></a></li>";
	$("#"+classifyId).html(html);
}

//加载一级菜单信息
function loadMsg(data,classifyId,classifyName){
	var objs = eval(jQuery.parseJSON(data));  
    var name = "";
    var id = "";
    var time = "";
    var author = "";
    var html = "<li><a href='#' onclick=\"closeChildrenClassifys('"+classifyId+"','"+classifyName+"')\"><span>"+classifyName+"</span></a></li>";
   	var html2 = "<h1 style='font-size: xx-large;padding-bottom: 20px;' align=\"center\">"+classifyName+"</h1>"
   	html2 += "<input type='hidden' id='classify_pname' value=\""+classifyName+"\">";
   	html2 += "<div style='text-align: center;padding-bottom: 4px;'>";
   	html2 += "<form id='classifyForm' action='../classify/add' method='post' enctype='multipart/form-data'>"
   	html2 += "<input type='hidden' id='classify_pid'  name='classify_pid' value=\""+classifyId+"\">";
   	html2 += "分类名：<input name='new_calssifyName' id='new_calssifyName' />&nbsp;";
   	html2 += "<span id='preview'><img id='imghead' width=100 height=100 border=0 src='<%=request.getContextPath()%>/view/images/jiahao.png'></span>"
   	html2 += "<input type='file' name='image' id='image' onchange='previewImage(this)' />"
   	html2 += "<a href='#' onclick='addClassify()'>新增分类</a></div>";
   	html2 += "</form>"
    html2 += "<table align='center' class='table2'>";
    html2 += "<tr><th>分类名</th><th>创建者</th><th>创建时间</th><th>操作</th></tr>";
    for(var key in objs){
    	id = objs[key].classify_id;
    	name = objs[key].classify_name;
    	time = objs[key].classify_createTime;
    	author = objs[key].classify_author;
    	html += "<div id=\""+id+"\"><li><a style=\"background: url('images/sidebar_1.png') center center no-repeat;\" href='#' onclick=\"getArticle('"+id+"','"+name+"')\"><span>"+name+"</span></a></li></div>";//二级菜单
    	html2 += "<tr><td><input id='classifyName_"+id+"' value=\""+name+"\"/></td><td>"+author+"</td><td>"+time+"</td><td><a href='#' onclick=\"updateClassify('"+id+"','"+classifyId+"','"+classifyName+"')\">更新</a>&nbsp;<a href='#' onclick=\"deleteClassify('"+id+"','"+classifyId+"','"+classifyName+"')\">删除</a></td></tr>";
    }
    html2 += "</table>";
    $("#"+classifyId).html(html);
    $("#text").html(html2);
}

//根据分类id查找该分类下的文章
function getArticle(classifyId,classifyName){
		var pathName=window.document.location.pathname;
		var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
			$.ajax({
				type : 'POST',
				url : projectName+"/article/list",
				data : "classifyId="+classifyId,
				async : false,
				success : function(data,status){ 
			        if(status == "success"){  
			        	loadArticleMsg(data,classifyId,classifyName);
			        }  
				}
			});
	
}
//加载文章视图
function loadArticleMsg(data,classifyId,classifyName){
	var objs = eval(jQuery.parseJSON(data));  
    var articleTitle = "";
    var articleId = "";
    var articleTime = "";
    var articleAuthor = "";
   	var html2 = "<h1 style='font-size: xx-large;padding-bottom: 20px;' align=\"center\">"+classifyName+"</h1>"
   	html2 += "<input type='hidden' id='classifyId' value=\""+classifyId+"\">";
   	html2 += "<input type='hidden' id='classifyName' value=\""+classifyName+"\">";
   	html2 += "<div style='text-align: center;padding-bottom: 4px;'><a href='#' onclick=\"toAddArticle('"+classifyId+"')\">新增文章</a></div>";
    html2 += "<table align='center' class='table2'>";
    html2 += "<tr><th>文章标题</th><th>创建者</th><th>创建时间</th><th>操作</th></tr>";
    for(var key in objs){
    	articleId = objs[key].article_id;
    	articleTitle = objs[key].article_title;
    	articleTime = objs[key].article_createTime;
    	articleAuthor = objs[key].article_author;
    	html2 += "<tr><td>"+articleTitle+"</td><td>"+articleAuthor+"</td><td>"+articleTime+"</td><td><a href='#' onclick=\"toAddArticle('"+classifyId+"','"+articleId+"')\">更新</a>&nbsp;<a href='#' onclick=\"deleteArticle('"+articleId+"','"+classifyId+"','"+classifyName+"')\">删除</a></td></tr>";
    }
    html2 += "</table>";
    $("#text").html(html2);
	
}
//跳转到添加文章界面
function toAddArticle(classifyId,articleId){
	if(articleId == undefined){
		articleId = null;
	}
	var pathName=window.document.location.pathname;
	var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
	window.open(projectName+"/article/toadd?classifyId="+classifyId+"&articleId="+articleId);
}

//删除文章
function deleteArticle(articleId,classifyId,classifyName){
	if(confirm("你确定要删除该文章吗？")){
	var pathName=window.document.location.pathname;
	var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
		$.ajax({
			type : 'POST',
			url : projectName+"/article/delete",
			data : "articleId="+articleId,
			async : false,
			success : function(data,status){ 
		        if(status == "success"){  
		        	getArticle(classifyId,classifyName);
		        }  
			}
		});
	}
}
//图片上传预览    IE是用了滤镜。
function previewImage(file)
{
  var MAXWIDTH  = 260; 
  var MAXHEIGHT = 180;
  var div = document.getElementById('preview');
  if (file.files && file.files[0])
  {
      div.innerHTML ='<img id=imghead>';
      var img = document.getElementById('imghead');
      img.onload = function(){
        var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
        img.width  =  100;
        img.height =  100;
//         img.style.marginLeft = rect.left+'px';
        img.style.marginTop = '0px';
      }
      var reader = new FileReader();
      reader.onload = function(evt){img.src = evt.target.result;}
      reader.readAsDataURL(file.files[0]);
  }
  else //兼容IE
  {
    var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
    file.select();
    var src = document.selection.createRange().text;
    div.innerHTML = '<img id=imghead>';
    var img = document.getElementById('imghead');
    var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
    status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
    div.innerHTML = "<div id=divhead style='width:100;height:100;margin-top:0px;"+sFilter+src+"\"'></div>";
  }
}
function clacImgZoomParam( maxWidth, maxHeight, width, height ){
    var param = {top:0, left:0, width:width, height:height};
    if( width>maxWidth || height>maxHeight )
    {
        rateWidth = width / maxWidth;
        rateHeight = height / maxHeight;
         
        if( rateWidth > rateHeight )
        {
            param.width =  maxWidth;
            param.height = Math.round(height / rateWidth);
        }else
        {
            param.width = Math.round(width / rateHeight);
            param.height = maxHeight;
        }
    }
     
    param.left = Math.round((maxWidth - param.width) / 2);
    param.top = Math.round((maxHeight - param.height) / 2);
    return param;
}
</script>
<style type="text/css">
body{
    margin:0;
    padding:0;
    font-size:12px;
    background:url(images/body_bg.jpg) repeat-x #0099DD;
}
.zh-cn body{font-family: STHeiti,"Microsoft YaHei", "微软雅黑", "SimSun", "宋体",arial;}
.zh-tw body{font-family: "Microsoft JhengHei","微軟正黑體",arial,helvetica,sans-serif;}
#mainBody{
    min-width: 1020px;
    background: url('images/bg01.jpg') #E7F2F4 top center repeat-x;
}
.first #mainBody{background: url('images/bg01.jpg') #FFF top center repeat-x;}
#page-container{background: url('images/container_bg.jpg') center -100px no-repeat;}

/* header */
.login_BTN{background:url('images/btn_login.png') no-repeat;}
.login-joinus a{background-image:url('images/btn_joinus.png');}
/*footer*/
.footer-ad{background-image:url('images/footer_img.png');}
/* banner-title */
.banner-title{background-image:url('images/title_madvertis.png');}
.MemberExclusiveII .banner-title{background-image:url('images/title_memberexclusiveii.png');}
.ltlottery .banner-title{background-image:url('images/title_lottery.png');}
.ttlivetop .banner-title,
.ttlive .banner-title,
.lblive .banner-title,
.yslive .banner-title {
    background-image:url('images/title_live.png');
}
.btn-download,
.btn-download span{background-image: url('images/btn_download.png');}
.btn-service,
.btn-service span{background-image: url('images/btn_service.png');}
.btn-event,
.btn-event span{background-image: url('images/btn_events.png');}
/* GameIcon */
.GameIcon-First {background: url('images/First_zh-cn.png') left top no-repeat;}
</style>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/swfobject.js"></script>
<script type="text/javascript" src="js/swf.js" ></script>
<!--[if IE 6]>
<style type="text/css">
	html { overflow-x: hidden; }
</style>
<script type="text/javascript" src="js/iepng.js"></script>
<script type="text/javascript">
	EvPNG.fix('div, ul, img, li, input, a');
</script>
<script type="text/javascript" src="js/DD_belatedPNG_0.0.9a-min.js"></script>
<script type="text/javascript">
    $(function(){
        DD_belatedPNG.fix(".pngclass");
    });
	//修正ie6 bug
	try {
		document.execCommand("BackgroundImageCache", false, true);
	} catch(err) {}
</script>
<![endif]-->
<!-- revised -->
<script type="text/javascript">
//<![CDATA[

    //Global variable for calculating page generation time
    var PageInitTime = new Date();
    var GameType = '';

    //]]>
</script>
</head>
<body>
<div id="ele-lang-group" class="ele-lang-group">
                <a href="#" target="mem_index" class="ele-lang-option ele-lang-zh-tw ">
                </a>
                <a href="#" target="mem_index" class="ele-lang-option ele-lang-zh-cn ele-lang-current">
                </a>
                <a href="#" target="mem_index" class="ele-lang-option ele-lang-en ">
                </a>
                <style>
            .ele-lang-group{
                width:80px;
                display: none;
                position: absolute;
                z-index: 100;
                font-size: 12px;
                border-radius: 0 0 5px 5px;
                background-color: #FFFFFF;
                border-right:1px solid #AEAEAD;
                border-left:1px solid #AEAEAD;
                border-bottom:1px solid #AEAEAD;
            }
            .ele-lang-group a{
                height:22px;
                line-height: 22px;
                display: block;
                text-indent: 5px;
                text-decoration: none;
                color: #000;
            }
            

                        .ele-lang-wrap,
            .ele-lang-group{width: 54px; border-top:1px solid #AEAEAD;}
            .ele-lang-option{
                padding-left:20px;
                vertical-align: top;
                background: url('images/lang_circle.png') 50% 2px no-repeat;
                display: inline-block; *display: inline; *zoom: 1;
            }
            .ele-lang-zh-cn { background-position: 50% -38px; }
            .ele-lang-en    { background-position: 50% -78px; }
            .ele-lang-ja    { background-position: 50% -118px; }
            .ele-lang-km    { background-position: 50% -158px; }
            .ele-lang-vi    { background-position: 50% -198px; }
            .ele-lang-th    { background-position: 50% -238px; }
                        .ele-lang-current,
            .ele-lang-group a:hover{
                color: #000;
                background-color: #EFEFEF;
            }
        </style>
    </div>
    <div id="mainBody">
            <div id="page-header">
    <div id="header" class="clearfix">
        <div class="header-logo floatL">
                                                                        
        
<div id="ele-logo-wrap">
    <object width="210" height="110" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="/download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0">
        <param value="images/logo.swf" name="movie" />
        <param value="high" name="quality" />
        <param name="wmode" value="transparent" />
        <!-- <embed src="images/logo.swf" width="210" height="110" type="application/x-shockwave-flash" pluginspage="/www.macromedia.com/go/getflashplayer" quality="high" wmode="transparent">
    -->
    </object>
</div>

<style>
    #ele-logo-wrap{
        width: 210px;
        height: 110px;
        display: block;
        cursor: pointer;
    }
</style>

<script>
</script>        </div>
        <div id="header-top" class="floatL">
<style>
.ele-lang-wrap{
    line-height: 20px;
    width:80px;
    position: relative;
    top: 1px;
    z-index: 10;
    text-align: left;
    background: #FFFFFF;
    border:1px solid #AEAEAD;
    background: url('images/lang_arrow_down.jpg') right 1px no-repeat;
}
.ele-lang-title{
    height: 20px;
    line-height: 20px;
    cursor: pointer;
    padding-right: 15px;
    text-indent: 5px;
    color: #000;
}
    /* use flag and select */
    .ele-lang-title{
        height: 32px;
        margin-top: 5px;
    }
    .ele-lang-wrap,
    .ele-lang-group{width: 54px;}
</style>
			<div id="main-Menual">
               旅游管理系统后台
            </div>
        </div>
    </div>
            <div class="banner-wrap AT1">
            <div class="banner-title pngclass"></div>
        </div>
    </div>
    <div id="page-container">
    <div id="page-body" class="AT1 content-area clearfix">
        <!--    main   -->
                    <div id="page-left">
    <div class="gameMenuHeader pngclass"></div>
    <div class="gameMenuBody pngclass" id="menu_div">
            请稍等，正加载，。。。
    </div>
    <div class="gameMenuFooter pngclass"></div>
</div>
<div id="page-right">

<!--内容区 开始-->
<div id="content">
  <div id="left">
    <div id="text">
        <!--
      <div style="text-align:center; margin:0 20px 10px 0;">
      	<img src="../wuyi/shui.jpg" />
      </div>
      <p style="margin:10px 20px 10px 0;">应用平台:Win95/97/98/NT/2000/XP/2003</p>
      <p style="margin:10px 20px 10px 0;">软件大小：26247KB</p>
      <p style="margin:10px 20px 10px 0;">下载地址：</p>
       -->
       <p style="margin:10px 20px 10px 0;font-size: xx-large;">欢迎光临武夷山旅游后台管理</p>
    </div>
  </div>
</div>
<!--内容区域 结束-->

   </div>
</div>

<div id="page-footer" class="clearfix">
    <div class="footer-ad-wrap">
    </div>
        <div id="footer" class="clearfix">
        <!-- 廳主自改 -->
        <div id="ArticleList" class="link-warp-sytle">
                        <div id="FooterCopyright" class="link-warp-sytle">
                <p>
                    Copyright &copy; 哈哈工作室 Reserved &nbsp;&nbsp;24小时联系电话&nbsp;+63-99-8288-8888&nbsp;&nbsp;4006-931-368&nbsp;
                </p>
            </div>
        </div>
    </div>
</div>
</div>
</body>
</html>